<?php
MYTCONN();
  //==================== Procedures ============================
  if (isset($_GET['AMLID'])) {
 $OB_AML = $_GET['AMLID'];
  } else {
 $OB_AML = $_POST['amh_ID'];
  }
  $OB_Detl = $GLOBALS['MYT']->db_array("SELECT REF,
				TYPE,
				DB_Version,
 				STR_MATCHED,
 				STR_STORED,
 				INTERNAL_ID,
				EXTERNAL_ID,
 				sysTime,
				INVOICE,
				Observations,
				FraID, FraFechaIngreso, FraEnviado, CliNombre, BnfNombre, FraStatus, BnfBarrio, CliDomicilio
		FROM ex_matches
		INNER JOIN facturas ON INVOICE = FraID
			INNER JOIN clientes ON clientes.CliNumero = Facturas.FraCliNumero
			INNER JOIN beneficiarios ON beneficiarios.BnfNumero = Facturas.FraBnfNumero
   WHERE  = {$OB}");
  for ($f = 1; $f <= $OB_Detl[0]; $f++) {
	//=====================Invoice Form=========================
	form_pr('AMLEdit','',$GLOBALS['URL'].'_response/call.php?get=Compliance/op.amlpbc','post');
	mn_field('hidden','ED','amh_ID',$OB_AML,'','','','');
	mn_field('hidden','ED','amh_Operacion',$OB_Detl[$f]['amh_Operacion'],'','','','');  ?>
<div class="title">OFAC Match Information | <?php mn_field('button','ED','PRAML','Salvar','','','False','" onclick="subform(\'AMLEdit\',\'element\');');?></div>
<table width="100%"  border="0" cellspacing="0" cellpadding="3">
  <tr>
    <td valign="top"><table width="100%" cellpadding="2" cellspacing="0">
      <tr>
        <td width="36%">Match ID: </td>
        <td width="64%"><strong>
          <?php echo $OB_Detl[$f]['REF'];?>
        </strong></td>
      </tr>
      <tr>
        <td colspan="2"><strong>Beneficiario</strong><br>
		Nome: <?php echo $OB_Detl[$f]['BnfNombre'];?><br>
		Morada: <?php echo $OB_Detl[$f]['BnfBarrio'];?>
		<br>
		<strong>Cliente</strong><br>
		Nome: <?php echo $OB_Detl[$f]['CliNombre'];?><br>
		Morada: <?php echo $OB_Detl[$f]['CliDomicilio'];?></td>
        </tr>
      <tr>
        <td colspan="2"><strong>Registo OFAC </strong><br>
	<?php echo $OB_Detl[$f]['STR_STORED'];?></td>
        </tr>
      <tr>
        <td>Operacion: </td>
        <td><strong>
          <?php echo $OB_Detl[$f]['amh_Operacion'];?>
        </strong></td>
      </tr>
      <tr>
        <td>Opera&ccedil;&atilde;o</td>
        <td><?php
		if ($OB_Detl[$f]['FraStatus'] = 8) {
		mn_field('checkbox','ED','ConfBlock','','','','',''); echo 'Liberar remessa';
		} else {
		echo 'Remessa nao bloqueada'; ?></td>
      </tr>
      <tr>
        <td>Fecha: </td>
        <td><strong>
          <?php echo $OB_Detl[$f]['sysTime'];?>
        </strong></td>
      </tr>
      <tr>
        <td>Status: </td>
        <td><strong>
          <?php
	  $SearchStatus = "SELECT sttFlag AS ID, stt_Word AS NAME FROM hd_sysstatus WHERE stt_Sistema = 14";
	  mn_field('select','ED','STATUS',$OB_Detl[$f]['STATUS'],$SearchStatus,'','False','inputbox');
	  ?>
        </strong></td>
      </tr>
    </table></td>
    <td><table width="100%" cellpadding="2" cellspacing="1">
      <tr>
        <td colspan="3" valign="top">Anexos
<?php
mn_field('button','ED','Enviar ficheiros','Anexar ficheiro','','','False','inputbox"
onClick="newwindow(\'_response/call.php?get=Compliance/amh_docadd&ID='.$OB_Detl[$f]['amh_ID'].'\',\'Uploader\');'); ?></td>
        </tr>
	  <?php
	  $AMLDocs = 0;
	 /* $AMLDocs = $GLOBALS['MYT']->db_array("SELECT * FROM hd_docdocumentos
	  		INNER JOIN hd_doctipos ON dnc_ID = dnl_TipoDoc
	   WHERE dnl_AML = {$OB_Detl[$f]['amh_ID']}");*/
	  for ($d = 1; $d <= $AMLDocs[0]; $d++) {
	  	if ($d == 1) { ?>
      <tr bgcolor="#E9D9A0">
        <td valign="top">Tipo</td>
        <td valign="top">Ficheiro</td>
        <td valign="top">Data</td>
      </tr>
	  <?php } ?>
      <tr bgcolor="#E7EBE0">
        <td valign="top"><?php echo $AMLDocs[$d]['dnc_Doc'];?></td>
        <td valign="top"><a href="_response/bin.php?img=<?php
		$DCEXT = strlen($AMLDocs[$d]['dnl_FILE']);
		$DCEXT = substr($AMLDocs[$d]['dnl_FILE'],$DCEXT-3,3);
		echo md5($AMLDocs[$d]['dnl_ID']).'.'.$DCEXT;
		?>"><?php echo $AMLDocs[$d]['dnl_FILE'];?></a></td>
        <td valign="top"><?php echo $AMLDocs[$d]['dnl_FechaEntrega'];?></td>
        </tr>
	  <?php } ?>
      <tr>
        <td colspan="3" valign="top">Observa&ccedil;&otilde;es<br>
		<?php mn_field('textarea','ED','Observations',$OB_Detl[$f]['Observations'],'60','4','',''); ?></td>
        </tr>
    </table></td>
  </tr>
</table>
</form>
<table width="100%" cellpadding="2" cellspacing="0">
  <tr>
    <td colspan="5">Ordem Relacionada</td>
  </tr>
  <tr bgcolor="#CCCCCC">
    <td>Operacion</td>
    <td>Fecha</td>
    <td>Remitente </td>
    <td>Destinatario </td>
    <td>Montante</td>
  </tr>
  <tr>
    <td><?php echo $OB_Detl[1]['FraID'];?></td>
    <td><?php echo $OB_Detl[1]['FraFechaIngreso'];?></td>
    <td><?php echo $OB_Detl[1]['BnfNombre'];?></td>
    <td><?php echo $OB_Detl[1]['CliNombre'];?></td>
    <td><?php echo $OB_Detl[1]['FraEnviado'];?></td>
  </tr>
</table>
<?php } ?>